/**
 * 活性炭
 */
HuoBottle = Widget.extend({
	ctor:function(){
		this._super();
		this.init();
		this.setTag(TAG_HUOXINGTAN_BOTTLE);
	},
	init:function(){
		var body = new Button(this, 10, TAG_HUOXINGTAN, "#huoxingtan2.png", this.callback);
		var lid = new Button(this, 10, TAG_PINGSAI, "#pingsai.png", this.callback);
		lid.setPosition(0,40);

		var spoon = new Button(this, 8, TAG_GANGSHAO, "#spoon.png", this.callback);
		spoon.setPosition(150,0);

		var label = new cc.LabelTTF("活性炭",gg.fontName,12);
		label.setColor(cc.color(0,0,0));
		label.setPosition(25, 40);
		body.setCascadeOpacityEnabled(true);
		body.addChild(label, 11);
	},
	openLid:function(){
		var ber = cc.bezierBy(1,[cc.p(50,70),cc.p(60,-70),cc.p(60,-75)]);
		var rot=cc.rotateTo(1, 180);
		var spw=cc.spawn(ber,rot);
		var seq = cc.sequence(spw,this.func);
		this.getChildByTag(TAG_PINGSAI).runAction(seq);
	},
	rotateBody:function(){
		var rotate1 = cc.rotateTo(1,70);
		var delay = cc.delayTime(0.5);
		var rotate2 = cc.rotateTo(1,0);
		var seq = cc.sequence(rotate1,delay,rotate2);
		this.getChildByTag(TAG_HUOXINGTAN).runAction(seq);
		this.getChildByTag(TAG_HUOXINGTAN).runAction(rotate1);
	},
	callback:function(p){
		switch(p.getTag()){
		case TAG_PINGSAI:
			this.openLid();
			break;
		case TAG_GANGSHAO:
			var move1 = cc.moveTo(0.4,cc.p(100, 50));
			var rotate = cc.rotateTo(0.2,15);
			var move2 = cc.moveTo(0.4,cc.p(30,20));
			var delay = cc.delayTime(0.5);
			var func = cc.callFunc(function(p){
				p.setSpriteFrame("spoon3.png");
			}.bind(p),this);
			var move3 = cc.moveTo(0.5,cc.p(100,50));
			var move4=cc.moveTo(0.6, cc.p(150,-100));
			var seq = cc.sequence(move1,rotate,move2,delay,func,move3,move4,cc.callFunc(function() {
				p.setSpriteFrame("spoon.png");
			}, this),this.func);
			p.runAction(seq);
			this.rotateBody();
			break;
		}
	},
	actionDone:function(p){
		var beaker=this.getParent().getChildByTag(TAG_BEAKER);
		switch(p.getTag()){
		case TAG_PINGSAI:
			gg.flow.next();
			break;
		case TAG_GANGSHAO:
			this.setCascadeOpacityEnabled(true);
			this.runAction(cc.sequence(cc.delayTime(1),cc.callFunc(function() {
				this.removeFromParent();
			}, this)));
			beaker.showTan(true);
			break;
		}
		
	},
	
});